package com.ysh.mybatisdemo.controller;

import com.ysh.mybatisdemo.model.UserInfo;
import com.ysh.mybatisdemo.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/getAllUser")
    public List<UserInfo> getAllUser() {
        return userInfoService.getAllUser();
    }
    @RequestMapping("/getUserInfoById")
    public UserInfo getUserInfoById(Integer id){
        return userInfoService.getUserById(id);
    }

    @RequestMapping("/login")
    public boolean login(String username, String password){
        UserInfo userInfo = userInfoService.getUserByNameAndPassword(username, password);
        return userInfo ==null ?false :true;
    }
}
